package com.example.finaltool.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Objects;

/**
 * @author dengbw
 * @date 2021/8/10 3:40 下午
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class CmmFunctionConfigCheck {
    private String  defaultImages;
    private Integer userType;
    private Integer nhType;
    private Integer sortNo;

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof CmmFunctionConfigCheck)) {
            return false;
        }
        CmmFunctionConfigCheck c = (CmmFunctionConfigCheck) obj;
        return defaultImages.equals(c.defaultImages) && userType.equals(c.userType)
                    && checkNhType(c.nhType) && checkSortNo(c.sortNo);

    }

    @Override
    public int hashCode() {
        return Objects.hash(defaultImages, userType, nhType, sortNo);
    }

    private boolean checkNhType(Integer target) {
        if (target == null) {
            return this.nhType == null;
        } else {
            return target.equals(nhType);
        }
    }

    private boolean checkSortNo(Integer target) {
        if (target == null) {
            return this.sortNo == null;
        } else {
            return target.equals(this.sortNo);
        }
    }
}
